package com.program.beautymakeup.controller.wxController;

import com.program.beautymakeup.domain.vo.ResultInfo;
import com.program.beautymakeup.service.HomeService;
import com.program.beautymakeup.service.PortfolioTypeService;
import com.program.beautymakeup.service.UserService;
import com.program.beautymakeup.utils.ResultInfoUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author bytedance
 * @ClassName PortfolioController.java
 * @Description TODO
 * @createTime 2023年02月09日 22:17:00
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/portfolio")
public class PortfolioController {

    @Autowired
    private UserService userService;

    @Autowired
    private PortfolioTypeService portfolioTypeService;

    @Autowired
    private HomeService homeService;

    @GetMapping("/userList")
    public ResultInfo userList() {
        return ResultInfoUtil.buildSuccess(userService.userList());
    }

    @GetMapping("/typeList")
    public ResultInfo typeList() {
        return ResultInfoUtil.buildSuccess(portfolioTypeService.typeList());
    }

    @GetMapping("/list")
    public ResultInfo getAllList(@RequestParam(value = "pageNum", required = false) Integer pageNum,
                                 @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                 @RequestParam(value = "type",required = false) Integer type) {
        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 15;
        }
        return ResultInfoUtil.buildSuccess(homeService.getAllList(pageNum, pageSize, type));
    }

    @GetMapping("/userPortfolios")
    public ResultInfo getUserPortfolios(@RequestParam(value = "userId",required = true) Integer userId, @RequestParam(value = "type", required = false) Integer type) {

        return ResultInfoUtil.buildSuccess(homeService.getUserPortfoliosRsp(userId, type));
    }



}
